﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using TjZheng.News.DataEntity;

namespace TjZheng.News.Process
{
    public partial class BaseController
    {
        /// <summary>
        /// 获取版块文章列表
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadArticleContent"></param>
        /// <param name="isLoadPictureCollection"></param>
        /// <param name="isConvertTargetUrl"></param>
        /// <returns></returns>
        [OutputCache(Duration = 30)]
        public virtual JsonResult GetArticleList(int? categoryId, int? pageIndex = 1, int? pageSize = 10, int? isLoadArticleContent = 0, int? isLoadPictureCollection = 0, int? isConvertTargetUrl = 1)
        {
            return Json(CurrentProcess.GetArticleInfoList(categoryId, pageIndex, pageSize, isLoadArticleContent, isLoadPictureCollection, isConvertTargetUrl), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 获取版块文章列表
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadArticleContent"></param>
        /// <param name="isLoadPictureCollection"></param>
        /// <param name="isConvertTargetUrl"></param>
        /// <returns></returns>
        public virtual JsonResult GetArticleCollectList(int? parentId, int? pageIndex = 1, int? pageSize = 10, int? isLoadArticleContent = 0, int? isLoadPictureCollection = 0, int? isConvertTargetUrl = 1)
        {
            return Json(CurrentProcess.GetArticleCollectList(parentId, pageIndex, pageSize, isLoadArticleContent, isLoadPictureCollection, isConvertTargetUrl), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 搜索文章列表
        /// </summary>
        /// <param name="keyword">搜索关键字</param>
        /// <param name="categoryId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadArticleContent"></param>
        /// <param name="isLoadPictureCollection"></param>
        /// <param name="isConvertTargetUrl"></param>
        /// <returns></returns>
        [OutputCache(Duration = 30)]
        public virtual JsonResult GetSearchArticleCollectList(int? parentId, string keyword, int? pageIndex = 1, int? pageSize = 10, int? isLoadArticleContent = 0, int? isLoadPictureCollection = 0, int? isConvertTargetUrl = 1)
        {
            return Json(CurrentProcess.GetSearchArticleCollectList(parentId, keyword, pageIndex, pageSize, isLoadArticleContent, isLoadPictureCollection, isConvertTargetUrl), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 获取文章详情
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="articleId"></param>
        /// <param name="publishDate"></param>
        /// <param name="isLoadArticleContent"></param>
        /// <param name="isLoadPictureCollection"></param>
        /// <param name="isConvertTargetUrl"></param>
        /// <param name="isPictureThumbnail"></param>
        /// <param name="isContentThumbnail"></param>
        /// <returns></returns>
        [OutputCache(Duration = 30)]
        public virtual JsonResult GetArticleInfo(int? categoryId, int? articleId, string publishDate, int? isLoadArticleContent = 0, int? isLoadPictureCollection = 0, int? isConvertTargetUrl = 1, int? isPictureThumbnail = 0, int? isContentThumbnail = 0)
        {
            return Json(CurrentProcess.GetArticleInfo(categoryId, articleId, publishDate, isLoadArticleContent, isLoadPictureCollection, isConvertTargetUrl, isPictureThumbnail, isContentThumbnail), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 文章点击数+1
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="categoryId"></param>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public virtual JsonResult ViewArticle(int? parentId, int? categoryId, int? articleId)
        {
            return Json(CurrentProcess.ViewArticle(parentId, categoryId, articleId), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 文章点赞
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="categoryId"></param>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public virtual JsonResult DiggArticle(int? parentId, int? categoryId, int? articleId)
        {
            return Json(CurrentProcess.DiggArticle(parentId, categoryId, articleId), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 文章点踩
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="categoryId"></param>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public virtual JsonResult BuryArticle(int? parentId, int? categoryId, int? articleId)
        {
            return Json(CurrentProcess.BuryArticle(parentId, categoryId, articleId), JsonRequestBehavior.AllowGet);
        }
    }
}
